package cn.oms.oms.controller;

import cn.oms.oms.entity.Picking;
import cn.oms.oms.service.IPickingService;
import cn.oms.oms.vo.PickingVo;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author AllenChen曾晨
 * @since 2022-04-29
 */
@RestController
@RequestMapping("/oms/picking")
@Slf4j
public class PickingController {

    @Autowired
    public IPickingService pickingService;

    /**
     * 根据查询条件查询捡药列表
     * @param pickingVo
     * @return
     */
    @PostMapping("/selectPickingList")
    public PageInfo<Picking> selectPickingList(PickingVo pickingVo){
        if(pickingVo.getPageNum()==null||pickingVo.getPageNum()==0){
            pickingVo.setPageNum(1);
        }
        if(pickingVo.getPageSize()==null||pickingVo.getPageSize()==0){
            pickingVo.setPageSize(10);
        }
        log.debug("接收到信息:{}",pickingVo);
        PageInfo<Picking> pageInfo = pickingService.selectPickingList(pickingVo);
        return pageInfo;
    }
    /**
     * 新增捡药
     * @param pickingVo
     * @return
     */
    @PostMapping("/addPicking")
    public String addPicking(PickingVo pickingVo){
        log.debug("接收到信息:{}",pickingVo);
        String res = pickingService.addPicking(pickingVo);
        return res;
    }
    /**
     * 修改捡药
     * @param pickingVo
     * @return
     */
    @PostMapping("/updatePicking")
    public String updatePicking(PickingVo pickingVo){
        log.debug("接收到信息:{}",pickingVo);
        String res = pickingService.updatePicking(pickingVo);
        return res;
    }
    /**
     * 修改捡药
     * @param id
     * @return
     */
    @PostMapping("/deletePicking/{id}")
    public String deletePicking(@PathVariable Integer id){
        log.debug("接收到信息:{}",id);
        String res = pickingService.deletePicking(id);
        return res;
    }
    /**
     * 发药
     * @param pickingVo
     * @return
     */
    @PostMapping("/sendPicking")
    public String sendPicking(PickingVo pickingVo){
        log.debug("接收到信息:{}",pickingVo);
        String res = pickingService.sendPicking(pickingVo);
        return res;
    }

}
